package org.sabeot.enlistme.hibernate.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.sabeot.enlistme.hibernate.dao.UserDAO;
import org.sabeot.enlistme.hibernate.dto.UserDTO;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class UserDAOImpl extends AbstractDAOImpl<UserDTO, Long> implements UserDAO {

	private Logger logger = Logger.getLogger(UserDAOImpl.class);
	
	protected UserDAOImpl() {
		super(UserDTO.class);
	}

	@Transactional(readOnly = false)
	public void createNewUser(String login, String email, boolean isActive) {
	
		UserDTO user = new UserDTO(login, email, isActive);
		saveOrUpdate(user);
	}

	@Transactional(readOnly = true)
	public List<UserDTO> findAllUsers() {
		return findAll();
	}

}
